<?php
class ZBd
{
	const SECRET_KEY = '@4!@#$%@';

	static public function GenPassword($p) {
		return md5($p . self::SECRET_KEY);
	}

	static public function Create($bd_row) {
	}

	static public function GetBd($bd_id) {
		if (!$bd_id) return array();
		Table::Fetch('bd', $bd_id);
	}

	static public function GetLogin($username, $password, $en=true) {
		if($en) $password = self::GenPassword($password);
		return DB::GetTableRow('bd', array(
					'username' => $username,
					'password' => $password,
		));
	}

	static public function GetLoginBd() {
		if(isset($_SESSION['bd_id'])) {
			return self::GetBd($_SESSION['bd_id']);
		}
		return array();
	}

	static public function Login($bd_id) {
		Session::Set('bd_id', $bd_id);
	}
}
